package db_model

import (
	"time"

	"github.com/google/uuid"
)

// VerificationType represents the type of verification
type TicketType int16

// CAS Ticket Types
const (
	TicketTypeTGT TicketType = 1 // TGT (Ticket Granting Ticket)
	TicketTypeST  TicketType = 2 // ST (Service Ticket)
)

// CasTicket CAS票证模型
type CasTicket struct {
	ID          string     `gorm:"column:id;type:varchar(255);primaryKey" json:"id"`                               // TGT or ST value
	PrincipalID uuid.UUID  `gorm:"column:principal_id;type:uuid;not null" json:"principal_id"`                     // User Id
	ParentID    string     `gorm:"column:parent_id;type:varchar(255)" json:"parent_id"`                            // It is TGT when type is ST
	Type        TicketType `gorm:"column:type;type:smallint;not null;default:0" json:"type"`                       // 1: TGT, 2: ST
	ExpiredAt   time.Time  `gorm:"column:expired_at;type:timestamptz;not null" json:"expired_at"`                  // Expiration time
	CreatedAt   time.Time  `gorm:"column:created_at;type:timestamptz;default:CURRENT_TIMESTAMP" json:"created_at"` // Creation time
	UpdatedAt   time.Time  `gorm:"column:updated_at;type:timestamptz;default:CURRENT_TIMESTAMP" json:"updated_at"` // Updated time
	Remember    bool       `gorm:"column:remember;type:boolean;default:true" json:"remember"`                      // Remember me for TGT
}

// TableName 指定表名
func (CasTicket) TableName() string {
	return "cas_tickets"
}
